import { IsNumber, IsString, IsBoolean, IsOptional, IsDate, ValidateNested, IsInt } from "class-validator";
import { Type } from "class-transformer";

/**
 * 菜单关联角色响应DTO
 */
export class MenuRoleResponseDto {
  @IsNumber({}, { message: "角色ID必须是数字" })
  id: number;

  @IsString({ message: "角色名称必须是字符串" })
  name: string;

  @IsOptional()
  @IsString({ message: "角色描述必须是字符串" })
  description?: string;
}

/**
 * 菜单信息返回DTO
 */
export class MenuResponseDto {
  @IsNumber({}, { message: "菜单ID必须是数字" })
  id: number;

  @IsString({ message: "菜单名称必须是字符串" })
  name: string;

  @IsString({ message: "菜单路径必须是字符串" })
  path: string;

  @IsString({ message: "访问控制权限必须是字符串" })
  acl: string;

  @IsOptional()
  @IsInt({ message: "排序值必须是整数" })
  order?: number;

  @IsOptional()
  @IsDate({ message: "创建时间必须是有效日期" })
  @Type(() => Date)
  createdAt?: Date;

  @IsOptional()
  @IsDate({ message: "更新时间必须是有效日期" })
  @Type(() => Date)
  updatedAt?: Date;

  @IsOptional()
  @ValidateNested({ message: "角色信息格式不正确" })
  @Type(() => MenuRoleResponseDto)
  role?: MenuRoleResponseDto;
}
